<{*资金分配日志*}>
<style>
	.uploader input,.uploaderLogin input{opacity:0;position: relative;left:-30px;width:31px;display: inline-block;overflow: hidden}
</style>
<div class="row">
	<div id="breadcrumb" class="col-md-12">
		<ol class="breadcrumb">
			<li><a href="#">Dashboard</a></li>
			<li><a href="#">Tables</a></li>
			<li><a href="#">Data Tables</a></li>
		</ol>
	</div>
</div>
<div class="row">
	<div class="col-xs-12">
		<div class="box">
			<div class="box-header">
				<div class="box-name">
					<i class="fa fa-usd"></i>
					<span>资金分配记录</span>
				</div>
				<div class="box-icons">
					<a class="collapse-link">
						<i class="fa fa-chevron-up"></i>
					</a>
					<a class="expand-link">
						<i class="fa fa-expand"></i>
					</a>
					<a class="close-link">
						<i class="fa fa-times"></i>
					</a>
				</div>
				<div class="no-move"></div>
			</div>
			<div class="box-content no-padding">
				<table class="table table-bordered table-striped table-hover table-heading table-datatable" id="datatable-1">
					<thead>
						<tr>
							<th>日期</th>
							<th>渠道</th>
							<th>支付宝金额</th>
							<th>微信金额</th>
							<th>支付宝数量</th>
							<th>微信数量</th>
							<th>导出</th>
							<th>导入充值</th>
							<th>导入登陆</th>
							<th>删除</th>

						</tr>
					</thead>
					<tbody>
					<!-- Start: list_row -->
					<{foreach from=$list item=item}>
						<tr>
							<td><{$item['date']}></td>
							<td><{$item['channel']}></td>
							<td><{$item['alipay']}> <{if $item['unassignMoneyAli'] gt 0}>&nbsp;(<{$item['unassignMoneyAli']}>)<{/if}></td>
							<td><{$item['wxpay']}> <{if $item['unassignMoneyWeixin'] gt 0}>&nbsp;(<{$item['unassignMoneyWeixin']}>)<{/if}></td>
							<td><{$item['aliCount']}></td>
							<td><{$item['wxCount']}></td>
							<td><a href="/data/<{$item['export_xls']}>.xlsx" target="_blank"><{$item['export_xls']}></a><br />
								<a href="/data/<{$item['login_xls']}>.xlsx" target="_blank"><{$item['login_xls']}></a>
							</td>
							<td>
								<span class='uploader' data="<{$item['id']}>">
								<a href="javascript:void(0)"  class="import">导入<input type='file' id='file1' name='file' /></a>
									<i class="uptxt"><{if $item['import_xls'] }> <a href="<{$item['import_xls']}>" target="_blank">下载</a><{/if}></i>
								</span>
							</td>
							<td>
								<span class='uploaderLogin' data="<{$item['id']}>">
								<a href="javascript:void(0)"  class="import">导入<input type='file' id='file1' name='file' /></a>
									<i class="uptxt"><{if $item['login_xls'] }> <a href="<{$item['login_xls']}>" target="_blank">下载</a><{/if}></i>
								</span>
							</td>
							<td><a href="javascript:void(0)" data="<{$item['id']}>" class="delete">删除</a></td>
						</tr>

					<{/foreach}>

					<!-- End: list_row -->

					</tbody>
					<tfoot>
						<tr>
							<th>日期</th>
							<th>渠道</th>
							<th>支付宝金额</th>
							<th>微信金额</th>
							<th>支付宝数量</th>
							<th>微信数量</th>
							<th>导出</th>
							<th>导入</th>
							<th>删除</th>
						</tr>
					</tfoot>
				</table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
// Run Datables plugin and create 3 variants of settings
function AllTables(){
	TestTable1();
	LoadSelect2Script(MakeSelect2);
}
function MakeSelect2(){
	$('select').select2();
	$('.dataTables_filter').each(function(){
		$(this).find('label input[type=text]').attr('placeholder', 'Search');
	});
}



var uploadAssignURL='<{u("ajaxUpload?tp="|cat:$fileforRecharge)}>';
var uploadLoginURL='<{u("ajaxUpload?tp="|cat:$fileforLogin)}>';

(function ($) {
	'use strict';
	$.fn.uploaderAssign = function () {
		return this.each(function () {
			var $this = $(this);
			var $file = $this.find('input[type=file]');
			var $txt = $this.find('i.uptxt');
			var ruleId=$this.attr('data')
			$file.AjaxFileUpload({
				action: uploadAssignURL+'&rule='+ruleId,
				onSubmit: function () {
					$txt.text('上传中');
				},
				onComplete: function (filename, response) {
					if(response.status==0){
						$txt.text("上传成功");
					}else{
						alert(response.msg)
						$txt.text('出错');
					}

				}
			});
		});
	}
})(jQuery);
(function ($) {
	'use strict';
	$.fn.uploaderLogin = function () {
		return this.each(function () {
			var $this = $(this);
			var $file = $this.find('input[type=file]');
			var $txt = $this.find('i.uptxt');
			var ruleId=$this.attr('data')
			$file.AjaxFileUpload({
				action: uploadLoginURL+'&rule='+ruleId,
				onSubmit: function () {
					$txt.text('上传中');
				},
				onComplete: function (filename, response) {
					if(response.status==0){
						$txt.text("上传成功");
					}else{
						$txt.text(response.msg);
					}

				}
			});
		});
	}
})(jQuery);


$(document).ready(function() {
	// Load Datatables and run plugin on tables 
	LoadDataTablesScripts(AllTables);
	// Add Drag-n-Drop feature
	WinMove();

	$('.delete').on('click',function(){
		if(!window.confirm("删除后不可恢复，确定继续吗？")){
			return false;
		}
		var id=$(this).attr('data');
		var obj=this;
		$.post('<{u(moneyAssignDel)}>',{id:id},function(ret){
			if(ret.status==0){
				var $tr=$(obj).parent().parent();
				$tr.remove();
			}else{
				alert(ret.msg)
			}

		},'json');
	})

	$('.uploader').uploaderAssign();
	$('.uploaderLogin').uploaderLogin();
});


</script>
